package com.xijia.wuyouwallet.pref;
import android.content.Context;
import android.content.SharedPreferences;
import com.xijia.wuyouwallet.MyApp;

/**
 * Created by Administrator on 2017/7/31 0031.
 */

public class BasePref {

    protected Context mContext;

    protected SharedPreferences mSharedPref;

    BasePref(){
        mContext = MyApp.getInstance().getApplicationContext();
    }

    public void setSharedPref(SharedPreferences preferences){
        mSharedPref = preferences;
    }

    protected SharedPreferences getSp() {
        return mSharedPref;
    }

    public void putBooleanKey(String key, boolean setBool) {
        mSharedPref.edit().putBoolean(key, setBool).commit();
    }

    public boolean getBooleanKey(String key) {
        return mSharedPref.getBoolean(key, false);
    }

    public boolean getBooleanKeyDefaultTrue(String key) {
        return mSharedPref.getBoolean(key, true);
    }

    public boolean getBooleanKeyDefaultFalse(String key) {
        return mSharedPref.getBoolean(key, false);
    }

    public void putFloatKey(String key, Float setFloat) {
        mSharedPref.edit().putFloat(key, setFloat).commit();
    }

    public float getFloatKey(String key) {
        return mSharedPref.getFloat(key, 0);
    }

    public float getDefaultFloatKey(String key, float defaultFloat) {
        return mSharedPref.getFloat(key, defaultFloat);
    }

    public void putIntKey(String key, int setInt) {
        mSharedPref.edit().putInt(key, setInt).commit();
    }

    public int getIntKey(String key) {
        return mSharedPref.getInt(key, 0);
    }

    public int getIntDefault(String key, int defalt) {
        return mSharedPref.getInt(key, defalt);
    }

    public void putLongKey(String key, Long setLong) {
        mSharedPref.edit().putLong(key, setLong).commit();
    }

    public long getLongKey(String key) {
        return mSharedPref.getLong(key, 0);
    }

    public void putStringKey(String key, String setString) {
        mSharedPref.edit().putString(key, setString).commit();
    }

    /*public String getStringKey(String key) {
        return mSharedPref.getString(key, FusionCode.EMT_STR);
    }*/

    public String getDefaultStringKey(String key, String defaultString) {
        return mSharedPref.getString(key, defaultString);
    }

    /*public String getDefaultTimeStringKey(String key) {
        return mSharedPref.getString(key, FusionCode.DEAFAULT_TIME);
    }*/

}
